package org.yinxue.framework.jdbc;

import java.sql.Connection;
import java.util.List;

/**
 * 操作数据库的接口类 <br>
 * <pre>
 * </pre>
 *
 * @author zengjian
 * @create 2018-07-06 23:29
 * @since 1.0.0
 */
public interface Jdbc {

    <T> Integer insert(T entity) throws Exception;

    <T> Integer insertBatch(List<T> entityList) throws Exception;

    <T> Integer delete(T entity) throws Exception;

    <T> Integer update(T entity) throws Exception;

    <T> List<T> queryList(T entity) throws Exception;

    <T> Integer queryCount(T entity) throws Exception;

    void createDatabase(String databaseName) throws Exception;

    void createTable(String tableName, String databaseName) throws Exception;

    void executeSQL(String sql) throws Exception;

    interface JdbcAction<T> {
        /**
         * 回调
         *
         * @param con
         * @return
         * @throws Exception
         */
        T doAction(Connection con) throws Exception;
    }

}
